<?php
include('config.php');

/*
- addcategory (tutorial category)
-handle (handle queries from default)
-default -time being (approve/manage tutorials)


-addforumcategory (add forumcategory)
-addforum (Add forum)





*/

//------------------------------------------
//echo out a navigation panel
echo '
<center><a href="admin.php?action=theme">Theme</a>| <a href="admintemplate.php?action=addpage">Add Page</a> | <a href="admin.php">Admin</a> | <a href="admin.php?action=addcategory">Add Category</a> | </center>
';
//------------------------------------------

//------------------------------------------
//begin main navigation (tutorials.php?action=)
$url = $_GET['action'];
$url = secure($url);

switch ($url) {
        //--------------------------
        // case to add a tutorial category
        //--------------------------
    case "addcategory":
      
	  include('admin/addpagecategory.php');
       
        break;


	case "addpage":

		include('admin/addpage.php');
		
		break;
	 
    case "handle":
        //if nothing is submitted in the
        //row[] array, then error!
        if (empty($_POST['row'])) {
            echo "Nothing to delete/validate!";
        }
        if (isset($_POST['delete_tutorials'])) {
            $delete_array = $_POST['row'];

            //loop through each individual
            //item in the array

            foreach ($delete_array as $val) {
                //delete them!
                $query = "DELETE FROM pages WHERE id = '$val'";
                $result = mysql_query($query) or die(mysql_error());
            }
            echo "Page(s) deleted";
        } elseif (isset($_POST['validate_tutorials'])) {
            $validate_array = $_POST['row'];

            //loop through each individual
            //item in the array

            foreach ($validate_array as $val) {
                //update the status to 1 which means validated!
                $query = "UPDATE pages SET is_validated = '1' WHERE id = '$val'";
                $result = mysql_query($query) or die(mysql_error());
            }
            echo "Page(s) validated!";
        }
        break;
		
		//----------------------------------------------
		// Interface to add forum categories.
		//----------------------------------------------
		

		//------------------------------
		//ADDFORUM, YAY!
		//--------------------------------
		
		case "theme":
		
        include('admin/theme.php');  
		
		break;
		
        //--------------------------
        //default case, we show
        //all tutorials with actions
        //--------------------------
    default:
    
	include('admin/approve.php');
	
        break;
}


?>